CC	= gcc
AS	= nasm
RM	= rm -f
CFLAGS	= -nostdlib -nostdinc -fno-builtin -fno-stack-protector -m32 -g -O0
CPPFLAGS= -I../include
ASFLAGS = -felf

SOURCES	= crash.c console.c printk.c entry.c version.c string.c vsprintf.c

kernel.o: build
	$(LD) *.o -o kernel.o

build: $(SOURCES)
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $(SOURCES)

clean:
	$(RM) *.o *.d

%.d: %.c
	$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
	rm -f $@.$$$$
include $(subst .c,.d,$(SOURCES))
